package com.itheima.demo3.ZengDemo3;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName test3
 * @Author 16799
 * @Date 2025/9/29 20:21
 * @Version 1.0
 * @Description TODO
 **/
public class test3 {
    public static void main(String[] args) {
        try(
                BufferedReader buf = new BufferedReader(new FileReader("D:\\Idea\\IntelliJIDEA2023.3.2\\Code\\javaseProMax\\Day14JavasePro-HuangPuBan-Test\\src\\系统菜单.txt"));
                PrintStream ps = new PrintStream("D:\\Idea\\IntelliJIDEA2023.3.2\\Code\\javaseProMax\\Day14JavasePro-HuangPuBan-Test\\src\\系统菜单2.txt");
                ){
            List<String> menus = new ArrayList<>();
            String line;
            while ((line = buf.readLine()) != null){
                menus.add(line);
            }
            System.out.println("看看读取到集合的信息： ");
            System.out.println(menus);

            Collections.sort(menus);
            System.out.println(menus);

            for (String menu : menus) {
                String[] split = menu.split("-");
                System.out.println(split[0].length()==4 ? split[1] : "\t"+split[1]);
            }

            System.out.println("-------------把集合的信息再写出到文件中--------------");

            for (String menu : menus) {
                ps.println(menu);
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
